<template>
	<view>
		<view class="page page-bottom-bar newPrescript">
			<!-- 头部 -->
			<topBar backUrl="back" title="历史处方详情">
				<view class="font14 font-0078ff" @click="previewImage()">查看原始处方</view>
			</topBar>
			<!-- 患者信息 -->
			<view class="part1 box-shadow">
				<view class="font13 font-969696 flex-row-between">
					<view>NO:{{info.user_the_patient_info.code}}</view>
				</view>
				<view class="hospital font15 font-b tc">{{userInfo.doctor_info.hospital_name}}处方</view>
				<view class="item flex-row-start">
					<view>患者姓名</view>
					<view class="txt">{{info.user_the_patient_info.name}}</view>
				</view>
				<view class="item flex-row-start">
					<view>患者年龄</view>
					<view class="txt">{{info.user_the_patient_info.age}}岁</view>
				</view>
				<view class="item nob flex-row-start">
					<view>患者性别</view>
					<view class="txt">{{info.user_the_patient_info.sex}}</view>
				</view>
			</view>
			<!-- 诊断信息 -->
			<view class="part2 box-shadow">
				<view class="font14">诊断</view>
				<view class="txt-textarea font-ef9140">{{info.diagnose}}</view>
			</view>
			<!-- 药品信息 -->
			<view class="part3 box-shadow">
				<view class="prescript-list drugs-box">
					<block v-for="(item, index) in info.doctor_prescription_access" :key="index">
						<view class="item">
							<view class="part2">
								<view class="name font14">{{item.goods_name}} *{{item.number}}</view>
								<view class="font12 font-969696">用法用量：{{item.frequencys}}，{{item.consumptions}}，{{item.usages}}</view>
							</view>
						</view>
					</block>
				</view>
			</view>
		</view>
		<!-- 按钮 -->
		<view class="fix-bottom-btn flex-row-center">
			<view class="btn flex-row-center font-ffffff font15" @click="onEdit">使用该处方</view>
		</view>
	</view>
</template>

<script>
	import topBar from "@/components/ComTopBar.vue";
	export default {
		components: { topBar },
		data() {
			return {
				backUrl: '',
				familyId: '', // 就诊人的id
				doctorId: '', // 医生id
				prescriptId: '', // 处方id
				userInfo: {},
				info: {},
				imgs: [
					'https://static.ytswu.com/app/D2103-business-js/my/cbk.png',
					'https://static.ytswu.com/app/D2103-business-js/my/cbk.png'
				]
			}
		},
		onLoad(options) {
			this.familyId = options.familyId
			this.doctorId = options.doctorId
			this.prescriptId = options.id
			this.backUrl = '/pagesA/prescript/list?familyId=' + options.familyId + '&doctorId=' + options.doctorId

			this.$Http({
				url: 'detailsPrescription',
				data: {doctor_prescription_id: options.id}
			}).then(res => {
				if (res.code == 1) {
					res.data.user_the_patient_info.age = this.$base.Onage(res.data.user_the_patient_info.birthday)
					res.data.user_the_patient_info.sex = res.data.user_the_patient_info.sex == '1' ? '男' : '女'
					this.info = res.data
				} else {
					uni.showToast({ title: res.msg, icon: 'none' })
				}
			})

			// 获取用户信息
			this.$Http({
				url: 'getUserInfo',
				type: 'POST',
				data: {}
			}).then(res => {
				this.userInfo = res.data
			})
		},
		methods: {
			// 编辑(使用该处方)
			onEdit () {
				uni.navigateTo({
					url:  '/pagesA/prescript/newPrescript?familyId=' + this.familyId + '&doctorId=' + this.doctorId + '&prescriptId=' + this.prescriptId + '&type=history'
				})
			},
			// 图片放大
			previewImage (e) {
				uni.previewImage({
					current: 0,
					urls: this.imgs
				})
			}
		}
	}
</script>

<style lang="less">
	@import url("style.less");
</style>
